package com.leizi.igym.utils;

import com.leizi.igym.enums.FileUploadBizEnum;

/**
 * @Author: leizi0110
 * @CreateTime: 2024-04-10  21:53
 * @Description:
 */

public class COSUtils {

    /**
     *  解析url中图片的名字，便于删除照片,即COS文档中的Key值，针对emp的
     * @param url
     * @return: java.lang.String
     **/
    public static String  parseFileNameForEmp(String url){
        if ("".equals(url)){
            return "";
        }
        String key = url.substring(url.indexOf(FileUploadBizEnum.EMP_AVATAR.getValue()));
        return key;
    }

    /**
     *  解析url中图片的名字，便于删除照片,即COS文档中的Key值，针对Trainer的
     * @param url
     * @return: java.lang.String
     **/
    public static String  parseFileNameForTr(String url){
        if ("".equals(url)){
            return "";
        }
        String key = url.substring(url.indexOf(FileUploadBizEnum.TRAINER_AVATAR.getValue()));
        return key;
    }

    public static String  parseFileName(FileUploadBizEnum fileUploadBizEnum,String url){
        if ("".equals(url)){
            return "";
        }
        String key = url.substring(url.indexOf(fileUploadBizEnum.getValue()));
        return key;
    }
}


